package com.ztgf.shopping.api.client.epg;

import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import com.ztgf.shopping.models.bo.epg.EpgTopicBO;
import com.ztgf.shopping.models.dto.epg.EpgTopicDTO;
import com.ztgf.shopping.models.service.epg.IEpgTopicService;
import com.ztgf.shopping.models.vo.epg.EpgTopicVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: chenyu.wang
 * date: 2020-05-20 14:51
 * Description:
 */
@RestController
@RequestMapping("/api/epgTopic")
@Slf4j
@Api(value = "EpgTopicApiController", tags = "专题(推荐专区)Api接口")
public class EpgTopicApiController {


    @DubboReference
    private IEpgTopicService topicService;

    /**
     * 专题(推荐专区) 根据功能id
     * @param moduleId 功能id
     * @return
     */
    @ApiOperation(value = "专题(推荐专区)列表 根据功能id",notes = "专题(推荐专区)列表 根据功能id")
    @PostMapping("/getListByModuleId")
    public Result<List<EpgTopicVO>> getListByModuleId(Long moduleId){
        EpgTopicBO epgTopicBO = new EpgTopicBO();
        epgTopicBO.setModuleId(moduleId);
        List<EpgTopicVO> epgTopicVOList = topicService.getBySelectTopicInfoNoPage(epgTopicBO);
        return new Result<>(epgTopicVOList);
    }


    @PostMapping("/getById")
    @ApiOperation(value = "根据id查找", notes = "根据id查找")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    public Result<EpgTopicDTO> getById(@RequestParam Long id) {
        if (id == null) {
            return new Result<>(CodeEnum.FAIL_100002);
        }
        return new Result<>(topicService.selectById(id));
    }

    @PostMapping("/querySelectList")
    @ApiOperation(value = "专题(推荐专区)列表", notes = "专题(推荐专区)列表")
    public Result<List<EpgTopicVO>> querySelectList(EpgTopicBO topicBO) {
        if(null == topicBO)
            return new Result<>(CodeEnum.FAIL_100002 );
        List<EpgTopicVO> epgTopicVOList = topicService.getBySelectTopicInfoNoPage(topicBO);
        return new Result<>(epgTopicVOList);
    }
}
